home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Exchange
/
CD Exchange - Volume 1.iso
/
d.t.p
/
utils
/
others
/
pcal
/
pcalinit.ps
< prev
next >
Wrap
Text File
|
1992-02-21
|
14KB
|
602 lines
% pcalinit.ps - provides the PostScript routines for pcal.c
%
% 4.3 modified by Andrew Rogers:
%
% removed definitions of dategray and fillgray; handled instead by
% Pcal itself (may be selected by user via -s flag)
%
% enlarge dates in small and medium calendars; enlarge title and
% weekday names in medium calendars
%
% 4.2 modified by Andrew Rogers:
%
% support -[kK] options to reposition small calendars
%
% use same font size for "Notes" as for weekday names; delete heading
% from notes box if null
%
% move definition of notesfontsize to Pcal proper; tweak some of the
% routines to take variable font size into account
%
% add support for printing notes in any blank box on calendar and
% suppressing small calendars
%
% 4.1 modified by Andrew Rogers:
%
% support -G option (cf. prtday) to print "gray" dates as filled
% outlines
%
% 4.0 modified by Andrew Rogers:
%
% support -w ("whole year") option - cf. printmonth_[pl], startpage
% moved all the calendar calculations to pcal.c and moonphas.c (q.v.)
%
% support -B option (leave unused boxes blank)
%
% support -O option (print "gray" numbers as outlines)
%
% revised several of the basic routines and added some others; dates,
% moons, text, Julian days are now relative to upper-left corner of box
%
% enlarged title and dates in small calendars
%
% 3.0 modified by Andrew Rogers:
%
% added xsval, ysval, xtval, ytval for scaling and translation
% as per Ed Hand
%
% added day-of-year support (-j, -J flags)
%
% 2.6 * no modifications *
%
% 2.5 modified by Joe Brownlee:
%
% made day numbers smaller, providing more room for event text
% repositioned event text and moons accordingly
% added support for variable first day of week
%
% 2.4 * no modifications *
%
% 2.3 modified by Jamie Zawinski <jwz@lucid.com>:
%
% merged in moon routines (originally by Mark Hanson)
%
% 2.2 modified by Joe Brownlee:
%
% add "notetext" to print notes in unused calendar box
%
% 2.1 modified by Mark Kantrowitz:
%
% use symbolic names instead of magic numbers throughout
% support -L, -C, -R, -n options (all new)
% print holiday text in otherwise-wasted space next to date
% use larger text for dates in large calendars
%
% 2.0 modified by Andrew W. Rogers:
%
% skip printing days of week on small calendars
% center month and year at top of calendar
% use correct algorithm for leap year calculation
% get month and day names from main program
% use table to determine color (black/gray) of weekdays and holidays
% use hanging indent to print continued text lines
/SM 0 def % definitions for calendar sizes
/MED 1 def
/LG 2 def
/titlefontsize [ 60 52 48 ] def % font sizes for SM/MED/LG calendars
/datefontsize [ 60 48 25 ] def
/weekdayfontsize [ 0 28 12 ] def
/footfontsize 12 def
/titlepos [ 19 43 25 ] def % Y-offset (SM/MED/LG) of month/year title
/Y0 35 def % Y-coordinate of calendar grid origin
/daywidth 100 def % dimensions of grid boxes
/dayheight 80 def
/gridwidth daywidth 7 mul def
/gridheight dayheight 6 mul def
/negdaywidth daywidth neg def
/negdayheight dayheight neg def
/neggridwidth gridwidth neg def
/neggridheight gridheight neg def
/gridlinewidth 1.0 def % width of grid lines
/charlinewidth 0.1 def % width of outline characters
/moonlinewidth 0.1 def % width of moon icon line
/hangingindent ( ) def % for indenting continued text lines
%
% Utility functions:
%
/center { % print string centered in given width
/width exch def
/str exch def
width str stringwidth pop sub 2 div 0 rmoveto str show
} def
/strcat { % concatenate two strings
2 copy
length exch length
dup 3 -1 roll add
string
dup 0 6 -1 roll putinterval
dup 3 -1 roll 4 -1 roll putinterval
} def
/prtday { % print date in black, gray, outline, or filled outline
day 3 string cvs % convert to string
color (black) eq {
show
} if
color (gray) eq {
dategray setgray show
} if
color (outline) eq {
true charpath stroke
} if
color (outline_gray) eq {
true charpath
gsave dategray setgray fill grestore
stroke
} if
} def
/nextbox { % go to next column or start of next row
day startbox add 7 mod 0 eq % end of week?
{ neggridwidth daywidth add negdayheight rmoveto } % next row
{ daywidth 0 rmoveto } % next col
ifelse
} def
/boxpos { % push coords of upper-left corner of box <arg> (0..41)
dup 7 mod daywidth mul % x-coord
exch 7 idiv negdayheight mul Y0 add % y-coord
} def
/datepos { % push coords of upper-left corner of box for day <arg>
startbox add 1 sub dup 7 mod daywidth mul % x-coord
exch 7 idiv negdayheight mul Y0 add % y-coord
} def
%
% Functions for drawing parts of calendar:
%
/drawtitle { % draw month and year title
titlefont findfont titlefontsize calsize get scalefont setfont
/month_name month_names month 1 sub get def
/yearstring year 10 string cvs def
0 Y0 titlepos calsize get add moveto
month_name ( ) strcat yearstring strcat gridwidth center
} def
/drawdaynames { % draw day names above respective columns
dayfont findfont weekdayfontsize calsize get scalefont setfont
0 1 6 {
/i exch def
i daywidth mul Y0 5 add moveto
day_names i get
daywidth center
} for
} def
/drawgrid { % draw the grid for the calendar
gridlinewidth setlinewidth
0 daywidth gridwidth { % vertical lines
Y0 moveto
0 neggridheight rlineto
stroke
} for
0 negdayheight neggridheight { % horizontal lines
0 exch Y0 add moveto
gridwidth 0 rlineto
stroke
} for
} def
/drawnums { % place day numbers on calendar
dayfont findfont datefontsize calsize get scalefont setfont
/fontdiff datefontsize calsize get datefontsize LG get sub def
charlinewidth setlinewidth
1 datepos 20 fontdiff add sub exch 5 add exch moveto
1 1 ndays {
/day exch def
/color (black) def
calsize SM ne { % select alternate color
/gray day_gray day startbox add 1 sub 7 mod get def
holidays { day eq { /gray holiday_gray def } if } forall
gray {
/color logical_gray def
} if
} if
gsave
prtday
grestore
nextbox
} for
} def
/drawjnums { % place day-of-year numbers on calendar
notesfont findfont notesfontsize scalefont setfont
1 datepos dayheight 3 sub sub exch daywidth 3 sub add exch moveto
1 1 ndays {
/day exch def
/jday jdstart day add 1 sub def
/str jday 3 string cvs def
julian-dates true eq { % print days left in year?
/str str ( \050) strcat yearlen jday sub 3 string cvs
strcat (\051) strcat def
} if
gsave
str dup stringwidth pop 0 exch sub 0 rmoveto show
grestore
nextbox
} for
} def
/fillboxes { % used by drawfill to generate group of fill squares
/last exch def % last box to fill (41 = lower right box)
/first exch def % first box to fill (0 = upper left box)
first 1 last { % loop through range of boxes
/box exch def
/fillit true def
calsize LG eq { % skip note and small calendar boxes
noteboxes { box eq { /fillit false def } if } forall
box prev_small_cal eq box next_small_cal eq or {
/fillit false def
} if
} if
fillit { % move to position and fill the box
box boxpos moveto
gsave
fillgray setgray
daywidth 0 rlineto
0 negdayheight rlineto
negdaywidth 0 rlineto
closepath fill
grestore
} if
} for
} def
/drawfill { % generate fill squares where necessary
0 startbox 1 sub fillboxes % fill boxes before calendar
startbox ndays add 41 fillboxes % fill boxes after calendar
} def
/footstrings { % print foot strings at bottom of page
titlefont findfont footfontsize scalefont setfont
/bottomrow { neggridheight 20 add } def
0 bottomrow moveto
Lfootstring show
gridwidth Rfootstring stringwidth pop sub bottomrow moveto
Rfootstring show
0 bottomrow moveto
Cfootstring gridwidth center
} def
%
% Functions for printing text inside boxes:
%
/daytext {
/mytext exch def /day exch def
notesfont findfont notesfontsize scalefont setfont
day datepos datefontsize LG get notesfontsize add 2 sub sub dup
/ypos exch def exch 2 add exch moveto
currentpoint pop /LM exch def /RM LM 95 add def
showtext
} def
/holidaytext { % print text for holiday (next to date)
notesfont findfont notesfontsize scalefont setfont
/mytext exch def /day exch def
/